#include "processbar.h"
#include <time.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#define FILESIZE 1024*1024*1024

void download(callback_t cd)
{
    srand((unsigned int)time(NULL)^1023);

    int total = FILESIZE;
    while(total)
    {
        usleep(10000);//下载动作
        int one = rand()%(1024*1024*5);
        total -= one;
        if (total < 0) total = 0;

        //当前的下载进度
        double rate = (((FILESIZE - total)*1.0)/(FILESIZE))*100;
        cd(rate);
    } 
    printf("\n");

}

int main()
{
    //version1();
    download(version2);
    //char arr = 32;
    //printf("[\033[0m\033[1;31m%c\033[0m]\n",arr);
    //printf( "\033[42m\033[1m\003[0m\n");
    
    return 0;
}
